package com.demo;

import org.web3j.crypto.Credentials;
import org.web3j.crypto.WalletUtils;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.EthAccounts;
import org.web3j.protocol.core.methods.response.Web3ClientVersion;
import org.web3j.protocol.http.HttpService;

import java.io.File;

public class Test {


    public void test() {
        Web3j web3 = Web3j.build(new HttpService());
    }

    public static void main(String[] args) {
//        String baiwangRes =
//            "<business comment=\"发票作废\" id=\"FPZF\"><body yylxdm=\"1\"><fplxdm>发票类型代码</fplxdm><fpdm>发票代码</fpdm><fphm>发票号码</fphm><fpzt>作废状态</fpzt><zfrq>作废日期</zfrq> <returncode>00000000</returncode><returnmsg>成功</returnmsg> </body></business>";
//        XStream xstreamRes = new XStream(new XppDriver(new XmlFriendlyNameCoder("_-", "_")));
//        xstreamRes.ignoreUnknownElements(baiwangRes);
//        com.atour.pms.persistence.invoice.dto.baiwangResDto.Business bussinessRes = (com.atour.pms.persistence.invoice.dto.baiwangResDto.Business)xstreamRes.fromXML(baiwangRes);
//        System.out.println(JsonUtils.toJson(bussinessRes));

//        try {
//            String url = "http://106.12.196.21:8545/";
//            Web3j web3 = Web3j.build(new HttpService(url));
//
//            Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().send();
//            String clientVersion = web3ClientVersion.getWeb3ClientVersion();
//
//            System.out.println(clientVersion);
//
//
//            Web3ClientVersion web3ClientVersion1 = web3.web3ClientVersion().sendAsync().get();
//            String clientVersion1 = web3ClientVersion1.getWeb3ClientVersion();
//
//            System.out.println(clientVersion1);
//
//            Request<?, EthAccounts> ethAccountsRequest = web3.ethAccounts();
//            long id = ethAccountsRequest.getId();
//
//            System.out.println(id);
//
//            String account = "0x97bbd43dd14499d2807df6872990d81331ceeac0";
//
//            String jsonrpc = ethAccountsRequest.getJsonrpc();
//            System.out.println(jsonrpc);
//
//            //File resource = ResourceUtils.getFile("classpath:static/");
//            //String path = resource.getPath();
//
//            File file = new File("D:\\wt\\chain");
//
//            String s = WalletUtils.generateNewWalletFile(account, file, true);//方法返回创建的钱包文件名
//
//            System.out.println(s);
//
//            File aa = new File(file + File.separator + s);
//            Credentials credentials = WalletUtils.loadCredentials("123456",aa );
//            String address = credentials.getAddress();
//            System.out.println(address);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

           String codeNo="800";
           int num = getRandNum(10000000);
           String resNum = codeNo + num;
           while (resNum.equals("80080000")){

           }


    }

    public static int getRandNum(int length) {
//        int randNum=(int) ((Math.random()*9+1)*length);
        return 800000;
    }


}
